﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace StringComaprisionHomeWork
{
    class Program
    {

        public static bool myStringComparer(string line1, string line2)
        {
            bool result = false;
            if (line1.Length == line2.Length)
            {
                List<char> chLine1 = new List<char>();
                List<char> chLine2 = new List<char>();
                for (int i = 0; i < line1.Length; i++)
                {
                    chLine1.Add(line1[i]);
                    chLine2.Add(line2[i]);
                }

                chLine1.Sort();
                chLine2.Sort();
                int j=0;
                while (Convert.ToInt32(chLine1[j]) == Convert.ToInt32(chLine2[j]) && j < chLine1.Count-1)
                {
                    
                    j++;
                }
                if (j == chLine1.Count-1)
                {
                    result = true;
                }
                else
                {
                    result = false;
                }
                
            }
            else
            {
                result = false;
            }


            return result;
        }
        static void Main(string[] args)
        {
            List<string> linesArray1 = new List<string>();
            List<string> linesArray2 = new List<string>();
            using(StreamReader str = new StreamReader("TextFile1.txt"))
            {
                string line;
                while ((line = str.ReadLine()) != null)
                {
                    linesArray1.Add(line);
                }
            }

            using (StreamReader str = new StreamReader("TextFile2.txt"))
            {
                string line;
                while ((line = str.ReadLine()) != null)
                {
                    linesArray2.Add(line);
                    
                }
            }


            if (linesArray1.Count < linesArray2.Count)
            {
                for (int i = 0; i < linesArray2.Count; i++)
                {
                    if (myStringComparer(linesArray1[i], linesArray2[i]))
                    {
                        Console.WriteLine("Строки под номером " + Convert.ToInt32(i + 1) + " равны.");
                    }
                    else
                    {
                        Console.WriteLine("Строки под номером " + Convert.ToInt32(i + 1) + " не равны.");
                    }
                }
            }
            else
            {
                for (int i = 0; i < linesArray1.Count; i++)
                {
                    if (myStringComparer(linesArray1[i], linesArray2[i]))
                    {
                        Console.WriteLine("Строки под номером " + Convert.ToInt32(i + 1) + " равны.");
                    }
                    else
                    {
                        Console.WriteLine("Строки под номером " + Convert.ToInt32(i + 1) + " не равны.");
                    }
                }
            }
            Console.ReadLine();
        }
    }
}
